package com.sdx.coop.exam.service;

import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.sdx.common.utils.EDateUtil;
import com.sdx.coop.exam.dao.ExamPapersDao;
import com.sdx.coop.exam.entity.ExamPapers;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.Date;
import java.util.List;

/**
 * 试卷 Service
 */

@Service
@Transactional
public class ExamPapersService extends BaseService<ExamPapers>{

    @Resource
	private ExamPapersDao examPapersDao;

    public PageQuery<ExamPapers>queryByCondition(PageQuery query){
        PageQuery ret =  examPapersDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelExamPapers(List<String> ids){
        try {
            examPapersDao.batchDelExamPapersByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除试卷失败", e);
        }
    }

	public List<ExamPapers> all() {
		return examPapersDao.all();
		}

	public int selectPhoneCount(String startDate1, String endDate1) throws ParseException {
    	Date startDate = null;EDateUtil.parseDateYMDHMS(startDate1+" 00:00:00");
		Date endDate = null;EDateUtil.parseDateYMDHMS(endDate1+" 23:59:59");
		return examPapersDao.selectPhoneCount(startDate,endDate);
	}
	public List<BaseEntity> selectPhones(String startDate1, String endDate1) throws ParseException {
		Date startDate = EDateUtil.parseDateYMDHMS(startDate1+" 00:00:00");
		Date endDate = EDateUtil.parseDateYMDHMS(endDate1+" 23:59:59");
    	return examPapersDao.selectPhones(startDate, endDate);
	}

	public int selectPhoneCount(Date startDate, Date endDate) throws ParseException {
		return examPapersDao.selectPhoneCount(startDate,endDate);
	}
	public List<BaseEntity> selectPhones(Date startDate, Date endDate) throws ParseException {
		return examPapersDao.selectPhones(startDate, endDate);
	}
}